import mysql from 'mysql2/promise'

const pool = mysql.createPool({
  host: '127.0.0.1',
  port: 3306,
  user: 'root',
  password: '123456',
  database: 'music-min',
  connectionLimit: 10
})

async function addBanner() {
  try {
    // 添加陶喆专辑轮播图
    const [result] = await pool.query(
      'INSERT INTO banners (title, image, link, sort_order, status) VALUES (?, ?, ?, ?, ?)',
      [
        '陶喆 - 沙滩/Over the Rainbow',
        'https://ai-public.mastergo.com/ai/img_res/8404b597ab97241556ac1dce8d2c5ec2.jpg', // 使用现有的图片URL
        '',
        1,
        1
      ]
    )
    
    console.log('轮播图添加成功，ID:', result.insertId)
    
    // 查看所有轮播图
    const [rows] = await pool.query('SELECT * FROM banners ORDER BY sort_order ASC')
    console.log('当前轮播图列表:')
    console.table(rows)
    
  } catch (error) {
    console.error('添加轮播图失败:', error)
  } finally {
    await pool.end()
  }
}

addBanner()
